/*
 * @Description: 请输入....
 * @Author: Gavin
 * @Date: 2022-01-11 15:24:49
 * @LastEditTime: 2022-06-21 18:34:34
 * @LastEditors: Gavin
 */

const getUrlParams = (paramName) => {
  // 获取当前页面的 URL
  const url = new URL(window.location.href)
  const searchParams = url.searchParams

  // 获取指定参数的值
  const paramValue = searchParams.get(paramName)
  return paramValue
}

const user = [
  // ['000001', '郭晋锋', '总经办'],
  // ['000002', '刘珍珍', '运营部'],
  // ['000003', '宋峰', '运营部'],
  // ['000004', '高文凯', '网络部'],
  // ['000005', '程亚君', '网络部'],
  // ['000006', '郭兵兵', '网络部'],
  // ['000007', '赵鹏', '网络部'],
  // ['000008', '赵冠凯', '网络部'],
  // ['000009', '张翼飞', '软件部'],
  // ['000010', '高添', '软件部'],
  // ['000011', '陈金应', '软件部'],
  // ['000012', '郝敏', '软件部'],
  // ['000013', '崔瑞晨', '软件部'],
  // ['000014', '杨浩坤', '软件部'],
  // ['000015', '王静', '软件部'],
  // ['000016', '马俊楠', '软件部'],
  // ['000017', '张世平', '软件部'],
  // ['000018', '王磊', '市场部'],
  // ['000019', '王璇', '招标部'],
  // ['000020', '王鹏', '招标部'],
  // ['000021', '马晓伟', '市场部'],
  // ['000023', '王昕', '运营部'],
  // ['000024', '石娟娟', '运营部'],
  // ['000025', '白宇', '市场部']
]
/**
 * 卡片公司名称标识
 */
const COMPANY = '铂安'
/**
 * 奖品设置
 * type: 唯一标识，0是默认特别奖的占位符，其它奖品不可使用
 * count: 奖品数量
 * title: 奖品描述
 * text: 奖品标题
 * img: 图片地址
 * ROTATE_TIME:转的球速度越大越慢
 * circle:旋转圈数最好8*x倍数
 * enter: //抽奖进行时音乐
 * awards: //颁奖音乐
 */
let prizes = [
  {
    type: 0,
    count: 1000,
    title: '抽奖结束',
    text: '需要重新抽奖请配置后重置'
  },
  {
    type: 1,
    count: 1,
    text: '一等奖',
    title: '(平板电脑)',
    img: './img/pid.png',
    enter: 'bg4', //抽奖进行时音乐
    awards: '1st-BJ-BGM', //颁奖音乐
    ROTATE_TIME: 20000,
    circle: 8 * 6
  },
  {
    type: 2,
    count: 2,
    text: '二等奖',
    title: '(体检卡)',
    img: './img/3.png',
    enter: 'bg3', //抽奖进行时音乐
    awards: 'other-BJ-BGM', //颁奖音乐
    ROTATE_TIME: 20000,
    circle: 8 * 3
  },
  {
    type: 3,
    count: 3,
    text: '三等奖',
    title: '(双肩包)',
    img: './img/2.png',
    enter: 'bg3', //抽奖进行时音乐
    awards: 'other-BJ-BGM', //颁奖音乐
    ROTATE_TIME: 10000,
    circle: 8 * 3
  },
  {
    type: 4,
    count: 5,
    text: '幸运奖',
    title: '(小米键鼠)',
    img: './img/4.png',
    enter: 'bg3', //抽奖进行时音乐
    awards: 'other-BJ-BGM', //颁奖音乐
    ROTATE_TIME: 10000,
    circle: 8 * 3
  }
]
const pageType = getUrlParams('type')
if (pageType == 'add') {
  prizes = [
    {
      type: 0,
      count: 1000,
      title: '抽奖结束',
      text: '需要重新抽奖请配置后重置'
    },
    {
      type: 5,
      count: 10,
      text: '神秘大奖',
      title: '',
      img: './img/5.png',
      enter: 'bg5', //抽奖进行时音乐
      awards: '1st-BJ-BGM', //颁奖音乐
      ROTATE_TIME: 20000,
      circle: 8 * 2
    }
  ]
}

let prizeLocal = localStorage.getItem('prizeLocal')
let prizeLocalAdd = localStorage.getItem('prizeLocalAdd')
if (prizeLocal) {
  let prizeLocalData = JSON.parse(prizeLocal)
  // 神秘大奖个数为999
  if (prizes[1]) {
    prizes[1].count = prizeLocalData[0]
  }
  if (prizes[2]) {
    prizes[2].count = prizeLocalData[1]
  }
  if (prizes[3]) {
    prizes[3].count = prizeLocalData[2]
  }
  if (prizes[4]) {
    prizes[4].count = prizeLocalData[3]
  }
}
if (prizeLocalAdd) {
  let prizeLocalAddData = JSON.parse(prizeLocalAdd)
  const pageType = getUrlParams('type')
  if (pageType == 'add') {
    if (prizes[1]) {
      prizes[1].count = prizeLocalAddData[0]
    }
  }
}

let luckyData = JSON.parse(localStorage.getItem('luckyData')) || {} //中奖人员
let leftUsers = JSON.parse(localStorage.getItem('leftUsers')) || user //剩余人员

//不能说的秘密
const excludeUser = [['000005', '张无忌', '技术部']]

/**
 * @description: 不能说的秘密
 * @param {*} nowItem 当前奖品
 * @param {*} basicData 当前奖池人员
 * @return {*}
 * @Date: 2022-01-13 15:13:31
 */
function setSecret(nowItem, basicData) {
  if (nowItem.type != 4) {
    // console.log(mockData.excludeUser);
    // const excludeId = excludeUser.map(item => item[0])
    // console.log(excludeId, basicData.leftUsers);
    // basicData.leftUsers = basicData.leftUsers.filter(human => !excludeId.includes(human[0]))
    // console.log('leftUsers--?',basicData.leftUsers);
  }
}

//颜色
const rgba = '0,0,0'
//透明度
const opacity = () => 0.3 || Math.random() * 0.7 + 0.25
//气氛组卡片
const atmosphereGroupCard = () => `rgba(${rgba},${opacity()})`
//背景色
const background =''
  // 'url(https://sixos.oss-cn-beijing.aliyuncs.com/profile/upload/2024/12/19/bdf82d15083346d3996e8f3e538b8164.png)'
//背景动态壁纸模式 不用时可以设置为null或者注释
// const bgVideo="//game.gtimg.cn/images/lol/act/a20220121lunarpass/bg.mp4"
const width = window.innerWidth * 0.75
const height = window.innerWidth * 0.75 * 0.75
/**
 * 一次抽取的奖品个数与prizes对应
 */
const EACH_COUNT = [1, 1, 1, 1, 1]
export default {
  EACH_COUNT,
  prizes,
  COMPANY,
  user,
  // luckyData,
  // leftUsers,
  // awardList,
  excludeUser,
  atmosphereGroupCard,
  background,
  setSecret,
  width,
  height,
  bgVideo
}
